package cn.xzqwjw.taskmanager.common.exception;

import cn.xzqwjw.taskmanager.common.customEnum.ResponseCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author rush
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class CustomException extends RuntimeException {

  private String statusCode;
  private String message;

  /**
   * 无参构造方法
   */
  public CustomException() {
    super();
  }

  /**
   * 有参的构造方法
   */
  public CustomException(String message) {
    super(message);
    this.message = message;
  }

  public CustomException(String statusCode, String message) {
    this.statusCode = statusCode;
    this.message = message;
  }

  public CustomException(ResponseCodeEnum codeEnum) {
    this.statusCode = codeEnum.getStatusCode();
    this.message = codeEnum.getMessage();
  }

  @Override
  public String getMessage() {
    return message;
  }

}
